﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace IDataAccessLayer
{
    public interface IBaseDal<T> where T:class
    {
        bool Insert(T t);
        //bool Delete(object id);
        bool Delete(Expression<Func<T,bool>> match,bool isBatch=false);
        bool Update(Expression<Func<T,bool>> match , Expression<Func<T, T>> t);
        T Find(object id);
        T FindSingle(Expression<Func<T, bool>> match);
        /// <summary>
        /// 返回可查询的记录源
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetQueryable();

        ///// <summary>
        ///// 根据条件表达式返回可查询的记录源
        ///// </summary>
        ///// <param name="match">查询条件</param>
        ///// <param name="orderByProperty">排序表达式</param>
        ///// <param name="isDescending">如果为true则为降序，否则为升序</param>
        ///// <returns></returns>
        //IQueryable<T> GetQueryable(Expression<Func<T, bool>> match, string sortPropertyName, bool isDescending = true);

        /// <summary>
        /// 根据条件查询数据库,并返回对象集合
        /// </summary>
        /// <param name="match">条件表达式</param>
        /// <returns></returns>
        ICollection<T> Find(Expression<Func<T, bool>> match);

        ///// <summary>
        ///// 根据条件查询数据库,并返回对象集合
        ///// </summary>
        ///// <param name="match">条件表达式</param>
        ///// <param name="orderByProperty">排序表达式</param>
        ///// <param name="isDescending">如果为true则为降序，否则为升序</param>
        ///// <returns></returns>
        //ICollection<T> Find<TKey>(Expression<Func<T, bool>> match, Expression<Func<T, TKey>> orderByProperty, bool isDescending = true);
        ///// <summary>
        ///// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        ///// </summary>
        ///// <param name="match">条件表达式</param>
        ///// <param name="info">分页实体</param>
        ///// <param name="orderByProperty">排序表达式</param>
        ///// <param name="isDescending">如果为true则为降序，否则为升序</param>
        ///// <returns>指定对象的集合</returns>
        //ICollection<T> FindWithPager(Expression<Func<T, bool>> match, PagerInfo info);

        ///// <summary>
        ///// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        ///// </summary>
        ///// <param name="match">条件表达式</param>
        ///// <param name="info">分页实体</param>
        ///// <param name="orderByProperty">排序表达式</param>
        ///// <param name="isDescending">如果为true则为降序，否则为升序</param>
        ///// <returns>指定对象的集合</returns>
        //ICollection<T> FindWithPager<TKey>(Expression<Func<T, bool>> match, PagerInfo info, Expression<Func<T, TKey>> orderByProperty, bool isDescending = true);
    }
}
